import { App } from 'vue';
import { registerControlProvider } from '@ibiz-template/runtime';
import { withInstall } from '@ibiz-template/vue3-util';
import { OdooSearchBarControl } from './odoo-search-bar';
import { OdooSearchBarProvider } from './odoo-search-bar.provider';

export const IBizOdooSearchBarControl = withInstall(
  OdooSearchBarControl,
  function (v: App) {
    v.component(OdooSearchBarControl.name!, OdooSearchBarControl);
    registerControlProvider(
      'CUSTOM_ODOO_SEARCH_BAR',
      () => new OdooSearchBarProvider(),
    );
  },
);

export default {
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
  install(app: App) {
    app.use(IBizOdooSearchBarControl);
  },
};
